package com.a1anwang.okble.demo.ability;

import com.a1anwang.okble.demo.ResourceTable;
import com.a1anwang.okble.demo.base.BaseAbility;
import ohos.agp.components.Component;
import ohos.agp.window.service.DisplayAttributes;
import ohos.agp.window.service.DisplayManager;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

/**
 * Created by a1anwang.com on 2018/5/31.
 */
public class MainAbility extends BaseAbility {
    private static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, 0x00202, "TAG");
    @Override
    public boolean isFullScreen() {
        return false;
    }

    @Override
    public void setContentLayout() {
        setUIContent(ResourceTable.Layout_ability_main);
    }

    @Override
    public void beforeInitView() {
    }

    @Override
    public void initView() {
        findComponentById(ResourceTable.Id_btn_scan).setClickedListener(this);
        findComponentById(ResourceTable.Id_btn_peripheral).setClickedListener(this);
        findComponentById(ResourceTable.Id_btn_scan_beacon).setClickedListener(this);
        findComponentById(ResourceTable.Id_btn_be_beacon).setClickedListener(this);
        findComponentById(ResourceTable.Id_btn_monitor_beacon).setClickedListener(this);
    }

    @Override
    public void afterInitView() {

    }

    @Override
    public void onClickEvent(Component v) {
        String bundleName = getBundleName();
        switch (v.getId()) {
            case ResourceTable.Id_btn_scan:
                startAbility(bundleName, ScanAbility.class.getName());
                break;
            case ResourceTable.Id_btn_peripheral:
                startAbility(bundleName, AdvertiseAbility.class.getName());
                break;
            case ResourceTable.Id_btn_scan_beacon:
                startAbility(bundleName, ScanBeaconAbility.class.getName());
                break;
            case ResourceTable.Id_btn_be_beacon:
                startAbility(bundleName, BeIBeaconAbility.class.getName());
                break;
            case ResourceTable.Id_btn_monitor_beacon:
                startAbility(bundleName, MonitorBeaconRegionAbility.class.getName());
                break;
            default:
                break;
        }
    }
}
